package com.gitee.feizns.quickstart;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.Expiry;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.concurrent.TimeUnit;

/**
 * 快速开始{@link Cache}
 * @author feizns
 * @since 2025/4/14
 */
public class QkCaffeine {

//    public static void main(String[] args) {
//        Caffeines.getCache().put("key", "value");
//    }

    public static void main(String[] args) {
        Cache<String, Object> cache = Caffeine.newBuilder().expireAfter(new Expiry<String, Object>() {

            @Override
            public long expireAfterCreate(@NonNull String s, @NonNull Object o, long l) {
                return 0;
            }

            @Override
            public long expireAfterUpdate(@NonNull String s, @NonNull Object o, long l, @NonNegative long l1) {
                return 0;
            }

            @Override
            public long expireAfterRead(@NonNull String s, @NonNull Object o, long l, @NonNegative long l1) {
                return 0;
            }

        }).expireAfterWrite(1, TimeUnit.SECONDS).build();
//        cache.
//        build.
    }

}
